﻿package com.pixelbreaker.ui.osx
{
    import MacMouseWheel.as$70.*;
    import flash.display.*;
    import flash.events.*;
    import flash.external.*;
    import flash.system.*;

    public class MacMouseWheel extends Object
    {
        private var _clonedEvent:MouseEvent;
        private var _stage:Stage;
        private var _currItem:InteractiveObject;
        private static var instance:MacMouseWheel;

        public function MacMouseWheel(param1:SingletonEnforcer)
        {
            return;
        }// end function

        private function _setup(stage:Stage) : void
        {
            this._stage = stage;
            this._stage.addEventListener(MouseEvent.MOUSE_MOVE, this._getItemUnderCursor);
            if (ExternalInterface.available)
            {
                ExternalInterface.addCallback("externalMouseEvent", this._externalMouseEvent);
            }
            return;
        }// end function

        private function _externalMouseEvent(stage:Number) : void
        {
            var _loc_2:* = new MouseEvent(MouseEvent.MOUSE_WHEEL, true, false, this._clonedEvent.localX, this._clonedEvent.localY, this._clonedEvent.relatedObject, this._clonedEvent.ctrlKey, this._clonedEvent.altKey, this._clonedEvent.shiftKey, this._clonedEvent.buttonDown, int(stage));
            this._currItem.dispatchEvent(_loc_2);
            return;
        }// end function

        private function _getItemUnderCursor(event:MouseEvent) : void
        {
            this._currItem = InteractiveObject(event.target);
            this._clonedEvent = MouseEvent(event);
            return;
        }// end function

        public static function getInstance() : MacMouseWheel
        {
            if (instance == null)
            {
                instance = new MacMouseWheel(new SingletonEnforcer());
            }
            return instance;
        }// end function

        public static function setup(stage:Stage) : void
        {
            var _loc_2:* = Capabilities.os.toLowerCase().indexOf("mac") != -1;
            if (_loc_2)
            {
                getInstance()._setup(stage);
            }
            return;
        }// end function

    }
}
